
export default {
	install(Vue) {
		Vue.prototype._strMapToObj = function (strMap) {
			let obj = Object.create(null);
			for (let [k, v] of strMap) {
				obj[k] = v;
			}
			return obj;
		}

		Vue.prototype._mapToJson = function (map) {
			return JSON.stringify(this._strMapToObj(map));
		}

		Vue.prototype.swapArray = function (arr, index1, index2) {
			arr[index1] = arr.splice(index2, 1, arr[index1])[0];
			return arr;
		}

		Vue.prototype.zIndexUp = function (arr, index) {
			if (index != 0) {
				this.swapArray(arr, index, index - 1)
			} else {
				this.$message({
					message: '已经到顶啦！！',
					type: 'warning',
				})
			}
		}
		Vue.prototype.zIndexDown = function (arr, index) {
			if (index + 1 != arr.length) {
				this.swapArray(arr, index, index + 1)
			} else {
				this.$message({
					message: '已经到底啦！！',
					type: 'warning',
				})
			}
		}
		Vue.prototype.delIndexArr = function (arr, index) {
			if (arr.length > 0) {
				arr.splice(index, 1)
			}

		}
	}
}